
	hostUrl = "/labManager";

function request(element,urlto,success,fail){
	if(element == null ){
		var element = {};
	}
	element.timestamp = new Date();
	element.encrypt_method = "md5";
	var jsondata = JSON.stringify(element);
 　 $.ajax({
           type:"POST",
           url:urlto,
           data:jsondata,
           dataType: 'json',
           contentType:'application/json',
           success:function(data){
           		success(data);
           },
           error:function(error){
           	fail(error);
           }
         });
}

function requestWithSession(element,urlto,success,fail,isAsync){
	if(localStorage.session){
		element.session = localStorage.session;
	}
	element.timestamp = new Date();
	element.encrypt_method = "md5";
	var jsondata = JSON.stringify(element);
	if(isAsync){
		$.ajax({
	            type:"POST",
	            url:urlto,
	            data:jsondata,
	            dataType: 'json',
							async: false,
	            contentType:'application/json',
	            success:function(data){
	            		success(data);
	            },
	            error:function(error){
	            	fail(error);
	            }
	          });
	}else {
		$.ajax({
	            type:"POST",
	            url:urlto,
	            data:jsondata,
	            dataType: 'json',
	            contentType:'application/json',
	            success:function(data){
	            		success(data);
	            },
	            error:function(error){
	            	fail(error);
	            }
	          });
	}
}

/**/
function removeNav(){
	var box = document.getElementsByClassName('navList')[0];
	if(localStorage.userLevel == 1){
		box.innerHTML = "<li class='liActive'><a href=''>主页</a></li>" +
		"<li><a href='setting.html'>个人信息设置</a></li>" +
		"<li><a href='javascript:;' onclick='loginOut();'>登出</a></li>";
	}
	if(localStorage.userLevel == 2){
		box.innerHTML = "<li class='liActive'><a href=''>主页</a></li>" +
		"<li><a href='personnalManagement.html'>人员管理</a></li>" +
		"<li><a href='setting.html'>个人信息设置</a></li>" +
		"<li><a href='javascript:;' onclick='loginOut();'>登出</a></li>";
	}
	if(localStorage.userLevel == 3){
		box.innerHTML = "<li><a href='personnalManagement.html'>人员管理</a></li><li><a href='resourceManage.html'>物资管理</a></li><li><a href='javascript:;' onclick='loginOut();'>登出</a></li>";
	}
}

function loginOut(){
  window.localStorage.session = '';
  var str =  window.location.href;
  var lastIndex = str.lastIndexOf('/');
  var hrefUrl = str.substring(0,lastIndex);
  window.location.href = hrefUrl;
}
